import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.Border;


public class FileView extends JFrame {
	public JTextField filename;
	public JTextArea content;
	public JButton save;
	public JButton load;
	public JLabel label;
	
	public FileView() {
		filename = new JTextField();
		content = new JTextArea();
		load = new JButton("Load");
		save = new JButton("Save");
		label = new JLabel("File:");
		
		filename.setColumns(20);
		Dimension contentSize = new Dimension(640, 480);
		content.setPreferredSize(contentSize);
		
		/* Put them inside the JFrame */
		
		// Create the panels
		JPanel panel1 = new JPanel();
		FlowLayout layout1 = new FlowLayout();
		panel1.setLayout(layout1);
		
		JPanel panel2 = new JPanel();
		FlowLayout layout2 = new FlowLayout(FlowLayout.RIGHT);
		panel2.setLayout(layout2);
		
		Container root = this.getContentPane();
		root.setLayout(new BorderLayout());
		
		// Add components into their parent containers
		root.add(panel1, BorderLayout.NORTH);
		root.add(content, BorderLayout.CENTER);
		root.add(panel2, BorderLayout.SOUTH);
		
		panel1.add(label);
		panel1.add(filename);
		
		panel2.add(save);
		panel2.add(load);
		
		// Add some borders
		Border border1 = BorderFactory.createLineBorder(Color.black);
		panel1.setBorder(border1);
		Border border2 = BorderFactory.createEtchedBorder();
		panel2.setBorder(border2);
		content.setBorder(BorderFactory.createTitledBorder(border1, "File content:"));
		this.pack();
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
